
import * as moreIdexSearvices from '../../services/moreIndex'
export default {
  namespace: 'moreIndex',
  state: {typeNameList:[],getAllMoreInfoRes:[],getMoreState:null},
  reducers: {
    saveGetAllMoreInfo(state,{payload}){
      console.log("---------------payload",payload)
      return {
        ...state,typeNameList:payload.typeNameList,
        getAllMoreInfoRes:payload.getAllMoreInfoRes,
        getMoreState:payload.values.getMoreState,
      }



    },
    resetState(state,{payload}){
      return {
        ...state,getMoreState:payload.getMoreState
      }
    }








  },
  effects: {
    *getAllMoreInfo({payload:values},{call,put}){
      console.log("------------values",values)
      const {data} = yield call (moreIdexSearvices.getCourseIndexInfo,values)
      console.log("--------data",data)

      if (data.success == true) {
        let getAllMoreInfo = data.data.filter((item)=>{
          return item.groupId == values.groupId
        })
        console.log("--------getAllMoreInfo",getAllMoreInfo)
        let typeNameList = getAllMoreInfo[0].typeNameList
        let allTypeName = {typeName:'全部',typeNameId:-1}
        typeNameList.unshift(allTypeName)
        let getAllMoreInfoRes = getAllMoreInfo[0].courseList
        yield put({type:"saveGetAllMoreInfo",payload:{typeNameList,getAllMoreInfoRes,values}})



      }



      let typeNameList = [{ typeNameId: 1,typeNamePri:1, typeNameText: "java" },
          { typeNameId: 2,typeNamePri:2,  typeNameText: "ui" },
          { typeNameId: 3, typeNamePri:3, typeNameText: "ai" },]
      let getAllMoreInfoRes = [
        {
          "orgId": "云逸",
          "courseImgName": "courseClass-20170807175006.jpg",

          "courseId": 1001,
          "courseName": "数学一 张宇数学 强化班 ",
          "courseGroup": "轮播图",
          "courseType": "收费",
          "commonCash": 100,
          "commonYcoin": 10000,
          "discountPrice": 0,
          "discountYcoin": 0,
          "pushDate": "2017-08-07 17:50:07",
          "salesNum": 100,
          "keyTeacher":"我是主讲老师"
        },
        {
          "orgId": "云逸",
          "courseImgName": "courseClass-20170807175006.jpg",
          "courseId": 1002,
          "courseName": "数学一 张宇数学 强化班 ",
          "courseGroup": "轮播图",
          "courseType": "收费",
          "commonCash": 100,
          "commonYcoin": 10000,
          "discountPrice": 0,
          "discountYcoin": 0,
          "pushDate": "2017-08-07 17:50:07",
          "salesNum": 100,
          "keyTeacher":"我是主讲老师"

        },

        {
          "courseImgName": "courseClass-20170807175006.jpg",
          "courseId": 1003,
          "orgId": "云逸",
          "courseName": "数学一 张宇数学 强化班 ",
          "courseGroup": "轮播图",
          "courseType": "收费",
          "commonCash": 100,
          "commonYcoin": 10000,
          "discountPrice": 0,
          "discountYcoin": 0,
          "pushDate": "2017-08-07 17:50:07",
          "salesNum": 100,
          "keyTeacher":"我是主讲老师"
        },
        {
          "courseImgName": "courseClass-20170807175006.jpg",
          "courseId": 1004,
          "orgId": "云逸",
          "courseName": "数学一 张宇数学 强化班 ",
          "courseGroup": "轮播图",
          "courseType": "收费",
          "commonCash": 100,
          "commonYcoin": 10000,
          "discountPrice": 0,
          "discountYcoin": 0,
          "pushDate": "2017-08-07 17:50:07",
          "salesNum": 100,
          "keyTeacher":"我是主讲老师"
        },
        {
          "courseImgName": "courseClass-20170807175006.jpg",
          "courseId": 1005,
          "orgId": "云逸",
          "courseName": "数学一 张宇数学 强化班 数学一 张宇数学 强化班数学一 张宇数学 强化班数学一 张宇数学 强化班",
          "courseGroup": "轮播图",
          "courseType": "收费",
          "commonCash": 100,
          "commonYcoin": 10000,
          "discountPrice": 90,
          "discountYcoin": 9000,
          "pushDate": "2017-08-07 17:50:07",
          "salesNum": 100,
          "keyTeacher":"我是主讲老师"
        },

]








        }






  },
  subscriptions: {},
};
